/*
 * @Author: lcy
 * @Date: 2023-06-30 11:35:06
 * @Last Modified by: lcy
 * @Last Modified time: 2023-06-30 21:25:44
 */

import { API_HOME_CONFIG } from '@/config/api/home'
import { request } from '@/utils/request'
import { BasicMangeType } from '@/interface/common'
import { UserMangeType } from '@/interface/model/user'
interface HomeSeriviceInterface {
  getCarouselList: (params: { type?: number; pagesize?: number; pagecount?: number }) => Promise<any>
  getGoodsList: (params: { pagesize?: number; pagecount?: number }) => Promise<any>
}
export const useHomeSerivice = function (): HomeSeriviceInterface {
  class UserService {
    public getCarouselList(params: { type?: number; pagesize?: number; pagecount?: number }) {
      const url = API_HOME_CONFIG.getCarouselList()
      return request
        .get(url, { params })
        .then(({ data }: BasicMangeType.IAxiosResponse) => {
          return Promise.resolve(data)
        })
        .catch((err: any) => {
          return Promise.reject(err)
        })
    }
    public getGoodsList(params: { pagesize?: number; pagecount?: number }) {
      const url = API_HOME_CONFIG.getGoodsList()
      return request
        .get(url, { params })
        .then(({ data }: BasicMangeType.IAxiosResponse) => {
          return Promise.resolve(data)
        })
        .catch((err: any) => {
          return Promise.reject(err)
        })
    }
  }
  return new UserService()
}
